<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>PATH (variable)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/PATH_(variable)"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-PATH_variable rootpage-PATH_variable skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">PATH (variable)</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<style data-mw-deduplicate="TemplateStyles:r1251242444">
/* start https://en.wikipedia.org/ */
.mw-parser-output .ambox{border:1px solid #a2a9b1;border-left:10px solid #36c;background-color:#fbfbfb;box-sizing:border-box}.mw-parser-output .ambox+link+.ambox,.mw-parser-output .ambox+link+style+.ambox,.mw-parser-output .ambox+link+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+style+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+link+.ambox{margin-top:-1px}html body.mediawiki .mw-parser-output .ambox.mbox-small-left{margin:4px 1em 4px 0;overflow:hidden;width:238px;border-collapse:collapse;font-size:88%;line-height:1.25em}.mw-parser-output .ambox-speedy{border-left:10px solid #b32424;background-color:#fee7e6}.mw-parser-output .ambox-delete{border-left:10px solid #b32424}.mw-parser-output .ambox-content{border-left:10px solid #f28500}.mw-parser-output .ambox-style{border-left:10px solid #fc3}.mw-parser-output .ambox-move{border-left:10px solid #9932cc}.mw-parser-output .ambox-protection{border-left:10px solid #a2a9b1}.mw-parser-output .ambox .mbox-text{border:none;padding:0.25em 0.5em;width:100%}.mw-parser-output .ambox .mbox-image{border:none;padding:2px 0 2px 0.5em;text-align:center}.mw-parser-output .ambox .mbox-imageright{border:none;padding:2px 0.5em 2px 0;text-align:center}.mw-parser-output .ambox .mbox-empty-cell{border:none;padding:0;width:1px}.mw-parser-output .ambox .mbox-image-div{width:52px}@media(min-width:720px){.mw-parser-output .ambox{margin:0 10%}}@media print{body.ns-0 .mw-parser-output .ambox{display:none!important}}
/* end https://en.wikipedia.org/ */
</style>
<p><b>PATH</b> is an <a href="Environment_variable" title="Environment variable">environment variable</a> on <a href="Unix-like" title="Unix-like">Unix-like</a> <a href="Operating_system" title="Operating system">operating systems</a>, <a href="DOS" title="DOS">DOS</a>, <a href="OS/2" title="OS/2">OS/2</a>, and <a href="Microsoft_Windows" title="Microsoft Windows">Microsoft Windows</a>, specifying a set of <a href="Directory_(file_systems)" class="mw-redirect" title="Directory (file systems)">directories</a> where executable programs are located. In general, each executing <a href="Process_(computing)" title="Process (computing)">process</a> or <a href="Login_session" title="Login session">user session</a> has its own PATH setting.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="History">History</h2></div>
<p><a href="Multics" title="Multics">Multics</a> originated the idea of a search path. The early <a href="Unix_shell" title="Unix shell">Unix shell</a> only looked for program names in <code>/bin</code>, but by <a href="Version_3_Unix" class="mw-redirect" title="Version 3 Unix">Version 3 Unix</a> the directory was too large and <code>/usr/bin</code>, and a search path, became part of the operating system.<sup id="cite_ref-reader_1-0" class="reference"><a href="#cite_note-reader-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Unix_and_Unix-like">Unix and Unix-like</h2></div>
<p>On <a href="POSIX" title="POSIX">POSIX</a> and Unix-like operating systems, the <b><code>$PATH</code></b> variable is specified as a list of one or more directory names separated by colon (<code>:</code>) characters.<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup>
Directories in the <code>PATH</code>-string are not meant to be escaped, making it impossible to have directories with <code>:</code> in their name.<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup>
</p><p>The <code>/bin</code>, <code>/usr/bin</code>, and <code>/usr/local/bin</code> directories are typically included in most users' <code>$PATH</code> setting (although this varies from implementation to implementation). The <a href="Superuser" title="Superuser">superuser</a> also typically has <code>/sbin</code> and <code>/usr/sbin</code> entries for easily executing <a href="System_administration" class="mw-redirect" title="System administration">system administration</a> commands. The current directory (<code>.</code>) is sometimes included by users as well, allowing programs residing in the <a href="Current_working_directory" class="mw-redirect" title="Current working directory">current working directory</a> to be executed directly. System administrators as a rule do <i>not</i> include it in <code>$PATH</code> in order to prevent the accidental execution of scripts residing in the current directory, such as may be placed there by a malicious <a href="Tarbomb" class="mw-redirect" title="Tarbomb">tarbomb</a>. In that case, executing such a program requires specifying an absolute (<code>/home/userjoe/bin/script.sh</code>) or relative path (<code>./script.sh</code>) on the command line.
</p><p>When a command name is specified by the user or an <a href="Exec_(operating_system)" class="mw-redirect" title="Exec (operating system)">exec</a> call is made from a program, the system searches through <code>$PATH</code>, examining each directory from left to right in the list, looking for a <a href="Filename" title="Filename">filename</a> that matches the command name. Once found, the program is executed as a <a href="Child_process" title="Child process">child process</a> of the command shell or program that issued the command.
</p>
<div class="mw-heading mw-heading2"><h2 id="DOS,_OS/2,_and_Windows">DOS, OS/2, and Windows</h2></div>
<p>On DOS, OS/2, and Windows operating systems, the <b><code>%PATH%</code></b> variable is specified as a list of one or more directory names separated by semicolon (<code>;</code>) characters.<sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup>
</p><p>The Windows system directory (typically <code>C:\WINDOWS\system32</code>) is typically the first directory in the path, followed by many (but not all) of the directories for installed software packages. Many programs do not appear in the path as they are not designed to be executed from a <a href="Command_shell" class="mw-redirect" title="Command shell">command window</a>, but rather from a <a href="Graphical_user_interface" title="Graphical user interface">graphical user interface</a>. Some programs may add their directory to the front of the PATH variable's content during installation, to speed up the search process and/or override OS commands. In the DOS era, it was customary to add a <code class="mw-highlight mw-highlight-lang-dosbatch mw-content-ltr" dir="ltr"><span class="k">PATH</span> {program directory};<span class="nv">%PATH%</span></code> or <code class="mw-highlight mw-highlight-lang-dosbatch mw-content-ltr" dir="ltr"><span class="k">SET</span> <span class="nv">PATH</span><span class="p">=</span>{program directory};<span class="nv">%PATH%</span></code> line to <a href="AUTOEXEC.BAT" title="AUTOEXEC.BAT">AUTOEXEC.BAT</a>.
</p><p>When a command is entered in a command shell or a system call is made by a program to execute a program, the system first searches the <a href="Current_working_directory" class="mw-redirect" title="Current working directory">current working directory</a> and then searches the path, examining each directory from left to right, looking for an <a href="Executable" title="Executable">executable</a> filename that matches the command name given. Executable programs have <a href="Filename_extension" title="Filename extension">filename extensions</a> of <code><a href="EXE" class="mw-redirect" title="EXE">EXE</a></code> or <code><a href="COM_file" title="COM file">COM</a></code>, and batch scripts have extensions of <code><a href="Batch_file" title="Batch file">BAT</a></code> or <code><a href="CMD_file_(CP/M)" title="CMD file (CP/M)">CMD</a></code>. Other executable filename extensions can be registered with the system as well.
</p><p>Once a matching executable file is found, the system <a href="Spawn_(computing)" title="Spawn (computing)">spawns</a> a new process that runs it.
</p><p>The PATH variable makes it easy to run commonly used programs located in their own folders. If used unwisely, however, the value of the PATH variable can slow down the operating system by searching too many locations, or invalid locations.
</p><p>Invalid locations can also <i>stop</i> services from running altogether, especially the 'Server' service which is usually a dependency for other services within a Windows Server environment.
</p>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */
.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}
/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-reader-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-reader_1-0">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */
.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}
/* end https://en.wikipedia.org/ */
</style><cite id="CITEREFMcIlroy1987" class="citation techreport cs1"><a href="Doug_McIlroy" class="mw-redirect" title="Doug McIlroy">McIlroy, M. D.</a> (1987). <a rel="nofollow" class="external text" href="http://www.cs.dartmouth.edu/~doug/reader.pdf"><i>A Research Unix reader: annotated excerpts from the Programmer's Manual, 1971–1986</i></a> <span class="cs1-format">(PDF)</span> (Technical report). CSTR. Bell Labs. 139.</cite></span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://www.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap08.html#tag_08_03">Open Group Unix Specification, Environment Variables</a></span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://www.opengroup.org/onlinepubs/000095399/functions/execve.html">Open Group Unix Specification, execve() function</a></span>
</li>
<li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="https://git.kernel.org/pub/scm/utils/dash/dash.git/tree/src/exec.c?h=v0.5.9.1&id=afe0e0152e4dc12d84be3c02d6d62b0456d68580#n173">Dash exec.c as an example of an implementation of a PATH-string parser</a></span>
</li>
<li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://msdn.microsoft.com/en-us/library/aa922003.aspx">Microsoft.com, PATH command</a></span>
</li>
</ol></div></div></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-07-29" href="https://en.wikipedia.org/wiki/?title=PATH_(variable)&oldid=1303243174">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
</body></html>